#ifndef ULN2003_DRIVER_H
#define ULN2003_DRIVER_H


#include "sys_pub.h"

// ULN2003 channel index definitions
// ULN2003 通道枚举：严格匹配原理图的“ULNx_yy”命名
typedef enum {
    // ---------------- U13 (原理图标识：ULN1) ----------------
    ULN1_16, ULN1_15, ULN1_14, ULN1_13, 
    ULN1_12, ULN1_11, ULN1_10, 
    // ---------------- U24 (原理图标识：ULN2) ----------------
    ULN2_16, ULN2_15, ULN2_14, ULN2_13, 
    ULN2_12, ULN2_11, ULN2_10, 
    // ---------------- U32 (原理图标识：ULN3) ----------------
    ULN3_16, ULN3_15, ULN3_14, ULN3_13, 
    ULN3_12, ULN3_11, ULN3_10, 

    // ---------------- U27 (原理图标识：ULN4) ----------------
    ULN4_16, ULN4_15, ULN4_14, ULN4_13, 
    ULN4_12, ULN4_11, ULN4_10, 
    // ---------------- U20 (原理图标识：ULN5) ----------------
    ULN5_16, ULN5_15, ULN5_14, ULN5_13, 
    ULN5_12, ULN5_11, ULN5_10, 
    // ---------------- U18 (原理图标识：ULN6) ----------------
    ULN6_16, ULN6_15, ULN6_14, ULN6_13,

    ULN_CH_MAX  // 总通道数（必须与数组长度一致）
} uln_channel_t;

/**
 * @brief Initialize ULN2003 driver and associated hardware
 * @param None
 * @return None
 */
void uln_init(void);

/**
 * @brief Set state of a specific ULN2003 channel
 * @param channel: ULN channel index (ULN_CH_U01 to ULN_CH_U23)
 * @param state: 1 for high level, 0 for low level
 * @return 1 if successful, 0 if invalid channel
 */
uint8_t uln_set_channel(int channel, uint8_t state);

/**
 * @brief Get current state of a specific ULN2003 channel
 * @param channel: ULN channel index (ULN_CH_U01 to ULN_CH_U23)
 * @return 1 if high, 0 if low, 0xFF if invalid channel
 */
uint8_t uln_get_channel(uln_channel_t channel);

#endif /* ULN2003_DRIVER_H */
    